#!/bin/sh
# shellcheck shell=dash disable=SC2169,SC3010 source=/dev/null
#
# Starts eq3configcmd setlgwkey.
#

[[ -r /var/hm_mode ]] && . /var/hm_mode

# skip this startup if not in normal mode
[[ "${HM_MODE}" != "NORMAL" ]] && exit 0

start() {
  echo -n "Setting LAN Gateway keys: "
  if ls /etc/config/*.keychange >/dev/null 2>&1; then
    /bin/setlgwkey.sh
    echo "OK"
  else
    echo "not required"
  fi
}

restart() {
  start
}

case "$1" in
  start)
    start
  ;;
  stop)
    # nothing
  ;;
  restart|reload)
    restart
  ;;
  *)
    echo "Usage: $0 {start|restart}"
    exit 1
esac

exit 0
